package org.jeecg.modules.simulator.model;

import org.jeecg.modules.simulator.model.line.station.station.Station;
import org.jeecg.modules.simulator.model.line.station.strategy.ITrainStrategy;
import org.jeecg.modules.simulator.model.orbit.OrbitPath;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalTime;
import java.util.Map;

/**
 * @program: gp2
 * @description:
 * @author: renzhg
 * @create: 2024-09-10 13:14
 **/
public class LineHelper {

    @Setter
    @Getter
    private OrbitPath upOrbitPath;//上行轨道
    @Setter
    @Getter
    private OrbitPath downOrbitPath;//下行轨道


    public static String checkArriveStation(MetroTrain train){
        if(!train.getCurrentTrainActionRecorder().getAffiliateType().equals("docking")){
            return  null;
        }
        return train.getCurrentTrainActionRecorder().getName();

    }


    public static long getUniqueNumber() {
        long timestamp = System.currentTimeMillis(); // 获取当前时间戳
        long randomNumber = (long) (Math.random() * 1000); // 生成一个随机数
        return timestamp * 1000 + randomNumber; // 结合时间戳和随机数
    }

//    public static ITrainStrategy chooseStrategy(Station station) {
//        // 根据车站情况返回适当的策略
//        if (station.getStationTypeState()== StationTypeState.normal) {
//            return new NormalOffTrainStrategy();
//        } else if(station.getStationTypeState()==StationTypeState.end ){
//            return new ClearOffTrainStrategy();
//        }else{
//
//
//
//            return   new NormalOffTrainStrategy();
//        }
//    }

    /**
     * 策略模式的上下车执行
     * @param station
     * @param train
     * @param strategy
     * @return
     */
    public static   boolean doExchange(Station station,
                                       MetroTrain train,
                                       LocalTime now,
                                       Map<String, OffTrainNumRange> offTrainNumRangeMap,
                                       Map<String, Station> stationNameMap,
                                       ITrainStrategy strategy) {
        return strategy.trainExchange(train,offTrainNumRangeMap,stationNameMap,station ,now);
    }
}
